package com.zsoft.example;

import com.zsoft.util.ThreadUtil;

/**
 * 测试读写同时进行的响应中断操作
 * @author zuoshuaiok@gmail.com
 * local-search
 * 2013-3-30
 */
public class Main {
	public static void main(String[] args) {
		BufferInteruptly buffer = new BufferInteruptly();

		Writer w = new Writer(buffer);
		w.start();
		ThreadUtil.sleep(2);
		final Reader r = new Reader(buffer);
		r.start();

		new Thread() {
			@Override
			public void run() {
				ThreadUtil.sleep(200);
				System.out.println("尝试中断读线程");
				r.interrupt();
			}
		}.start();
	}
}
